var abs = function(x){
    if(x>=0){
        return x;
    }else{
        return -x;
    }
};

console.log(abs(-2));
console.log(abs(-2,'性价比','sdas'));
console.log(abs()); 




function foo(a, b, ...rest) {
    console.log('a = ' + a);
    console.log('b = ' + b);
    console.log(rest);
}

foo(1, 2, 3, 4, 5);
foo(1);

function area_of_circle(r,pi){
    if(pi===undefined){
        pi=3.14;
    }
    var d=r*r*pi;
    return d;
}
if (area_of_circle(2) === 12.56 && area_of_circle(2, 3.1416) === 12.5664) {
    console.log('测试通过');
} else {
    console.log('测试失败');
}



function max(a, b) {
    if (a > b) {
        return a;
    } else {
        return b;
        }
    }
console.log(max(15, 20));
